package com.example.xsssglxt.mapper;


import com.example.xsssglxt.entity.Student;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
@Mapper
public interface StudentMapper {
    @Select("select * from student_copy where name like concat('%' ,#{name},'%') AND sn like concat('%' ,#{sn},'%') limit #{pageNum},#{pageSize}")
  @Results(value =  {
          @Result(column = "create_time", property = "create_time", javaType = LocalDateTime.class, jdbcType = JdbcType.TIMESTAMP),
          @Result(column = "update_time", property = "update_time", javaType = LocalDateTime.class, jdbcType = JdbcType.TIMESTAMP)
  })
    List<Student> selectPage(Integer pageNum, Integer pageSize, String name, String sn);
    @Select("select count(*) from student_copy where name like concat('%' ,#{name},'%') or sn like concat('%' ,#{sn},'%')")
    Integer selectTotal(String name,String sn);
    @Select("select * from student_copy")
    @Results(value =  {
            @Result(column = "create_time", property = "create_time", javaType = LocalDateTime.class, jdbcType = JdbcType.TIMESTAMP),
            @Result(column = "update_time", property = "update_time", javaType = LocalDateTime.class, jdbcType = JdbcType.TIMESTAMP)
    })
    List<Student> selectlist();
    @Insert("Insert into student_copy(name,password,sex,sn) VALUES(#{name},#{password},#{sex},#{sn})")
    int insert(Student student);
  @Update("Update student_copy set name=#{name},password=#{password},sex=#{sex},sn=#{sn} where id=#{id}")
  int updatexs(Student student);
  @Delete("delete from student_copy where id=${id}")
  int deletxs(@Param("id") Integer id);
}
